package com.tfleo.mealssenger.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.Gallery;

public class SlowMotionGallery extends Gallery {
	public SlowMotionGallery(Context context, AttributeSet attrSet) {
		super(context, attrSet);
	}

	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY){
		//Limit the max speed in either direction
		if (velocityX > 0) {
			velocityX = 900.0f;
		} else if(velocityX < 0) {
			velocityX = -900.0f;
		}

		//return super.onFling(e1, e2, velocityX, velocityY);
		return false;
	}

	public boolean onScroll(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
		//Limit the max speed in either direction
		if (velocityX > 0) {
			velocityX = -800.0f;
		} else if(velocityX < 0) {
			velocityX = 800.0f;
		}

		return super.onFling(e1, e2, velocityX, velocityY);
	}
}
